<?php
/**
 * Dillenm-Mvc-Framework
 * 
 * A PHP MVC Framework written by Dillen Meijboom, all rights belong to him.
 * 
 * @license Copyright 2012 Dillen Meijboom under the Apache license version 2.0 (http://apache.org/licenses/LICENSE-2.0)
 * @author Dillen Meijboom <info@dillenm.nl>
 * @package System.library.Form.Validator
 * @url http://code.google.com/p/dillenm-mvc-framework/
 */

/**
 * Validate regular expression
 * 
 * @license Copyright 2012 Dillen Meijboom under the Apache license version 2.0 (http://apache.org/licenses/LICENSE-2.0)
 * @author Dillen Meijboom <info@dillenm.nl>
 * @package System.library.Form.Validator
 */

class Dmf_Form_Validator_Regex extends Dmf_Form_Validator
{
    protected $_message = 'Regular expression did not match';
    
    public function isValid( $value )
    {
        if ( substr( $this->_value, 0, 1 ) != '/' )
        {
            $this->_value = '/' . $this->_value . '/';
        }
        
        return preg_match( $this->_value, $value );
    }
}